import request from '../config/request.js';
import host from '../config/host';
import Cookies from 'js-cookie';

const getModuleCloudConfig = function(data, success) {
  const headers = {};
  const token = Cookies.get('GSESSIONID');
  if (token) {
    headers.GSESSIONID = token;
  }
  request.defaults({ method: 'post', url: host.pcHostUrl + `/pc/moduleCloudConfig/query`, data, success, headers });
};

//获取菜单
const getLeftMenu = function(data, success) {
  const headers = {};
  const token = Cookies.get('GSESSIONID');
  if (token) {
    headers.GSESSIONID = token;
  }
  request.defaults({ method: 'post', url: host.pcHostUrl + `/pc/moduleManage/query`, data, success, headers });
};

// 通知已读
const patchInformRecordStatus = function(data, success) {
  const headers = {};
  const token = Cookies.get('GSESSIONID');
  if (token) {
    headers.GSESSIONID = token;
  }
  request.defaults({ method: 'post', url: host.pcHostUrl + `/pc/informSendRecord/updateShowState`, data, success, headers });
};

const getInformConfig = function(data, success) {
  const headers = {};
  const token = Cookies.get('GSESSIONID');
  if (token) {
    headers.GSESSIONID = token;
  }
  request.defaults({ method: 'post', url: host.pcHostUrl + `/pc/informConfig/query`, data, success, headers });
};

export default {
  getModuleCloudConfig,
  getLeftMenu,
  patchInformRecordStatus,
  getInformConfig,
};
